<template>
  <div class="login-container">
    <img :src="logo" alt="" class="leftLogo" />
    <!-- 登录页主体 -->
    <div class="login-box shadow-[var(--el-box-shadow-light)] backdrop-blur-3px">
      <div w-full flex flex-col items-center>
        <!-- logo -->
        <el-image :src="logo" class="login-logo" />
        <!-- 组件切换 -->
        <transition name="fade-slide" mode="out-in">
          <component :is="formComponents[component]" v-model="component" class="w-100%" />
        </transition>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import logo from "@/assets/images/logo.png";
import { defaultSettings } from "@/settings";
import CommonWrapper from "@/components/CommonWrapper/index.vue";
import DarkModeSwitch from "@/components/DarkModeSwitch/index.vue";

type LayoutMap = "login" | "register" | "resetPwd";

const t = useI18n().t;

const component = ref<LayoutMap>("login"); // 切换显示的组件
const formComponents = {
  login: defineAsyncComponent(() => import("./components/Login.vue")),
  register: defineAsyncComponent(() => import("./components/Register.vue")),
  resetPwd: defineAsyncComponent(() => import("./components/ResetPwd.vue")),
};
</script>

<style lang="scss" scoped>
.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding-right: 6rem;
  .login-logo {
    width: 18.3125rem;
    margin-bottom: 4.4375rem;
  }
  .login-box {
    width: 43.25rem;
    background-color: #fff;
    border-radius: 2rem;
    padding: 4.0625rem 2.375rem 3.375rem;
  }
  .leftLogo {
    position: fixed;
    left: 4rem;
    top: 4rem;
    width: 12.9375rem;
  }
}

// 添加伪元素作为背景层
.login-container::before {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  content: "";
  background: url("@/assets/images/loginbgc.png");
  background-position: center center;
  background-size: cover;
}

.action-bar {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;

  @media (max-width: 480px) {
    top: 10px;
    right: auto;
    left: 10px;
  }

  @media (min-width: 640px) {
    top: 40px;
    right: 40px;
  }
}

/* fade-slide */
.fade-slide-leave-active,
.fade-slide-enter-active {
  transition: all 0.3s;
}

.fade-slide-enter-from {
  opacity: 0;
  transform: translateX(-30px);
}

.fade-slide-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
</style>
